<template>
  <el-row>
    <el-col id="pie" style="width:500px;height:380px;" class="pie"></el-col>
  </el-row>
</template>
<script lang="ts">
import { defineComponent, onMounted, getCurrentInstance } from 'vue'

export default defineComponent({
  name: 'pie',
  setup(props, { emit }) {
    onMounted(() => {
      const { proxy }: any = getCurrentInstance()
      // 基于准备好的dom，初始化echarts实例
      let myChart = proxy.$echarts.init(document.getElementById('pie'))
      let option = {
        legend: {
          top: 'bottom',
          textStyle: {
            color: '#fff',
          },
        },
        toolbox: {
          show: true,
          // feature: {
          //   mark: { show: true },
          //   dataView: { show: true, readOnly: false },
          //   restore: { show: true },
          //   saveAsImage: { show: true },
          // },
        },
        series: [
          {
            name: 'Nightingale Chart',
            type: 'pie',
            radius: [20, 150],
            center: ['50%', '45%'],
            roseType: 'area',
            itemStyle: {
              borderRadius: 8,
            },
            label: {
              textStyle: {
                color: '#fff',
              },
            },
            data: [
              { value: 40, name: 'rose 1' },
              { value: 38, name: 'rose 2' },
              { value: 32, name: 'rose 3' },
              { value: 30, name: 'rose 4' },
              { value: 28, name: 'rose 5' },
              { value: 26, name: 'rose 6' },
              { value: 22, name: 'rose 7' },
              { value: 18, name: 'rose 8' },
            ],
          },
        ],
      }
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option)
    })
  },
})
</script>

<style lang="scss" scoped>
.pie {
  border: 1px solid #fff;
  border-radius: 5px;
}
</style>